package com.atguigu.ai.chat.controller;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatModelController {
    @Autowired
    private ChatModel chatModel;

    @GetMapping("/chatModel01")
    public Flux<String> chatModel01(@RequestParam(value = "msg") String message) {
        return chatModel.stream(message);
    }

    @GetMapping("chatModel02")
    public Flux<String> chatModel02(@RequestParam(value = "msg") String message) {
        Flux<String> stream = chatModel.stream(
                new Prompt(message, ChatOptions.builder().model("deepseek-chat").temperature(0.8).build()).getContents());
        return stream;
    }
}
